<?php require_once 'include/head.php';?>
<!--h_r start-->
    <div class="h_r wd95 mA">
		<ul>
        	<li class="clearfix">
                <span class="fl wd35 texR">
                    姓名：　
                </span>
                    <font class="a"><?php echo $user['username'];?></font>
                    <input class="disB name" type="hidden" id="username" value="<?php echo $user['username'];?>" />
            </li>
            <li class="clearfix">
                <span class="fl wd35 texR">
                    余额：　
                </span>
                <span class="fl">
                    <font class="a"><?php echo $user['balance'];?></font>
                    <input class="disB name" type="hidden" id="balance"value="<?php echo $user['balance'];?>" />
                </span>
            </li>
            <li class="clearfix">
                <span class="fl wd35 texR">
                    转报单币金额：　
                </span>
                <input class="disB name" id="money" type="text" autocomplete="off" placeholder="请输入金额" />
            </li>
            <li class="clearfix">
                <span class="fl wd35 texR">
                    二级密码：　
                </span>
                <input class="disB name" type="password" id="password" autocomplete="off" placeholder="请输入二级密码" />
                <input class="disB btn cfff font14" id="zbtn" type="button" onclick="check();" value="申请报单" >
            </li>
        </ul>
    </div>
<!--h_r end-->
</body>
<script type="text/javascript">

	function check() {
	   var password = document.getElementById("password").value;
           var username = document.getElementById("username").value;
           var money = document.getElementById("money").value;
           money=parseInt(money);
           var balance=document.getElementById("balance").value;
            balance=parseInt(balance);
	   var data = {password:password,username:username};
	   var bool = true;

	   if(password ==  null ||password == '') {
		   $.alert({
			    title: '提示',
			    content:'密码不能为空',
			    confirm: function(){
			    }
			});
	        return false;
	   }
           if(money ==  null ||money == '') {
		   $.alert({
			    title: '提示',
			    content:'提现金额不能为空',
			    confirm: function(){
			    }
			});
	        return false;
	   }
           if(balance < money){
               $.alert({
			    title: '提示',
			    content:'金额不能大于余额',
			    confirm: function(){
			    }
			});
	        return false;
           }
	   $.ajax({
			url:"/wap/system_money/check_password",
			async: false,
			type:"post",
			data: data,
			dataType: 'json',
			success:function(data) {
				bool = data;
			}	
		});
		if(!bool) {
		   	$.alert({
			    title: '提示',
			    content:'密码错误',
			    confirm: function(){
			    }
			});
			 return false;	
		}
		$("#zbtn").attr("disabled", "disabled"); //使按钮不能被点击 
			$("#zbtn").attr("value", "提交中"); //更改按钮上的文字 
                var post_data = {password:password,username:username,money:money};
           $.ajax({
			url:"/wap/system_money/add",
			async: false,
			type:"post",
			data: post_data,
			dataType: 'json',
			success:function(data) {
				if(data.success){
                                   window.location.href='/wap/System_money';
                                }else{
                                    $.alert({
                                        title: '提示',
                                        content:data.msg,
                                        confirm: function(){
											$("#zbtn").removeAttr("disabled"); //使按钮能够被点击 
											$("#zbtn").attr("value", "申请报单"); //更改按钮上的文字
                                        }
                                    });
                                        return false;
                                }
			}	
		}); 
	   return true;
	}
        
        
</script>		
</html>